<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      class Controller {
        sum() {
          return this.data.reduce((t, c) => t + c.price, 0);
        }
      }
      class Lesson extends Controller {
        constructor(Lessons) {
          super();
          this.data = Lessons;
        }
        info() {
          return {
            totalPrice: super.sum(),
            data: this.data,
          };
        }
      }
      let data = [
        { name: 'js', price: 1090 },
        { name: 'mysql', price: 212 },
        { name: 'vue.js', price: 98 },
      ];
      let hd = new Lesson(data);
      console.log(hd.info());
    </script>
  </body>
</html>
